#include "win1_net_comm.h"


lv_obj_t *net_workLoading;

lv_obj_t *win1_net;

void WIN1_net_comm() // 网络连接加载界面
{
    win1_net = lv_obj_create(lv_scr_act());
    lv_obj_set_size(win1_net, 800, 480);
    lv_obj_set_style_pad_all(win1_net,0,0);
    lv_obj_clear_flag(win1_net, LV_OBJ_FLAG_SCROLLABLE);

    lv_obj_t* net_img = lv_img_create(win1_net);
    LV_IMG_DECLARE(net_comm);
    lv_img_set_src(net_img, &net_comm);

    net_workLoading = lv_spinner_create(win1_net);
    // lv_spinner_set_anim_params(ui_Spinner1, 1000, 90);
    lv_obj_set_width(net_workLoading, 80);
    lv_obj_set_height(net_workLoading, 80);
    lv_obj_align(net_workLoading, LV_ALIGN_CENTER,0,-20);
    lv_obj_remove_flag(net_workLoading, LV_OBJ_FLAG_CLICKABLE);
    lv_obj_set_style_bg_color(net_workLoading, lv_color_hex(0x191970), LV_PART_MAIN);
    
    lv_font_t * font = lv_freetype_font_create( "/home/gec/samba_share/001__lv_port_linux_ubuntu_sdl/my_project/Data/simkai.ttf", //字体文件路径
                                               LV_FREETYPE_FONT_RENDER_MODE_BITMAP,
                                               40,
                                               LV_FREETYPE_FONT_STYLE_NORMAL);

    if(!font) {
        LV_LOG_ERROR("freetype font create failed.");
        return;
    }

    /*Create style with the new font*/
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_text_font(&style, font);
    lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);

    lv_obj_t *ui_Label1 = lv_label_create(net_img);
    lv_obj_add_style(ui_Label1, &style, 0);
    lv_label_set_text(ui_Label1, "加载中...");
    lv_obj_align_to(ui_Label1, net_workLoading, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
    pthread_t net_pt;
    pthread_create(&net_pt, NULL, NET_comm, NULL);

}